import request from '@/utils/request'

/**
 * 新增用户
 * @param data
 * @returns {*}
 */
export function register(data) {
  return request({
    url: '/ticket-user/api/v1/ums/register',
    method: 'post',
    data: data
  })
}

/**
 * 用户登录
 * @param username
 * @param password
 * @returns {*}
 */
export function login(username, password) {
  return request({
    url: '/ticket-user/api/v1/ums/login',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

/**
 * 查看用户信息
 * @param username
 * @returns {*}
 */
export function getInfo(username) {
  return request({
    url: '/ticket-user/api/v1/ums/user?username=' + username,
    method: 'get',
  })
}

/**
 * 查看所有用户信息
 * @param username
 * @returns {*}
 */
export function getAllUsers() {
  return request({
    url: '/ticket-user/api/v1/ums/user/all',
    method: 'get',
  })
}

/**
 * 用户登出
 * @returns {*}
 */
export function logout() {
  return request({
    url: '/ticket-user/api/v1/ums/logout',
    method: 'post'
  })
}

/**
 * 更新用户信息
 * @param data
 * @returns {*}
 */
export function updateUser(data) {
  return request({
    url: '/ticket-user/api/v1/ums/user',
    method: 'put',
    data: data
  })
}

/**
 * 删除用户
 * @param username
 * @returns {*}
 */
export function deleteUser(username) {
  return request({
    url: '/ticket-user/api/v1/ums/user?username=' + username,
    method: 'delete'
  })
}
